<!--title-->
<div class="mnav1">
	<div class="m_nav">
		<div class="nav_left">
			<em class="home_icon"><?=$this->sys_name?></em><span>&nbsp;&gt;&nbsp;</span><font><?=$this->title?></font>
		</div>
	</div>
</div>

<div class="content-table2">
<div class="content-table-title"><?=$this->title?></div>
<div class="form-edit-task">

<form action="/dcc/companies-add-submit" method="post" name="form1" onsubmit="submitform(this);return false;">
<table border="0" width="100%">
	<tr>
		<td align="right">店铺名称：</td>
        <a href="companies-edit.phtml"></a>
		<td align="left">&nbsp;<input type="text" placeholder="店铺名称" name="company_name" id="company_name" style="width: 300px"><font color="red"> *</font></td>
	</tr>
	<tr>
        <td align="right">起始日：</td>
        <td align="left">&nbsp;<input type="text" name="start_date" id="start_date" style="width: 100px" autocomplete="off"></td>
    </tr>
	<tr>
		<td align="right">到期日：</td>
		<td align="left">&nbsp;<input type="text" name="expired_date" id="expired_date" style="width: 100px" autocomplete="off"></td>
	</tr>
	<tr>
		<td align="right">运营状态：</td>
		<td align="left">&nbsp;<select name="status" id="status">
					<option value="1">运营中</option>
					<option value="0">已关店</option>
				</select><font color="red"> *</font>
		</td>
	</tr>
	<tr>
		<td align="right">外显号码：</td>
		<td align="left">&nbsp;<input type="text" placeholder="外显号码" name="client_display_number" id="client_display_number" style="width: 300px"><font color="red"> 如果留空，无法使用电话条</font></td>
	</tr>
	<tr>
		<td align="right">营业时间开始：</td>
		<td align="left">&nbsp;<input type="text" placeholder="营业时间开始" name="biz_start" id="biz_start" value="09:00" style="width: 300px"><font color="red"> * 必填</font></td>
	</tr>
	<tr>
		<td align="right">营业时间结束：</td>
		<td align="left">&nbsp;<input type="text" placeholder="营业时间结束" name="biz_end" id="biz_end" value="18:00" style="width: 300px"><font color="red"> * 必填</font></td>
	</tr>
	<tr>
		<td align="right">首呼任务期限：</td>
		<td align="left">&nbsp;<input type="text" placeholder="首呼任务期限" name="period" id="period" value="1"><font color="red"> * 必填，小时</font></td>
	</tr>
	<tr>
		<td align="right">经理姓名：</td>
		<td align="left">&nbsp;<input type="text" placeholder="经理姓名" name="user_name" id="user_name"></td>
	</tr>
	<tr>
		<td align="right">经理手机：</td>
		<td align="left">&nbsp;<input type="text" placeholder="经理手机" name="cellphone" id="cellphone"><font color="red"> * 登录名，必填</font></td>
	</tr>
	<tr>
		<td align="right">经理登录密码：</td>
		<td align="left">&nbsp;<input type="text" placeholder="经理登录密码" name="pwd" id="pwd" value="123456"><font color="red"> * 登录密码，必填</font></td>
	</tr>
	<tr>
		<td align="right">负责运营：</td>
		<td align="left">&nbsp;<input type="text" placeholder="负责运营" name="staff_name" id="staff_name" style="width: 300px"></td>
	</tr>
    <tr>
        <td align="right">品牌：</td>
        <td align="left">&nbsp;<input type="text" placeholder="品牌" name="dealer_brand" id="dealer_brand" style="width: 300px"><font color="red"> * 品牌，必填</font></td>
    </tr>
    <tr>
        <td align="right">经销商地址：</td>
        <td align="left">&nbsp;<input type="text" placeholder="经销商地址" name="dealer_address" id="dealer_address" style="width: 300px"><font color="red"> * 经销商地址，必填</font></td>
    </tr>
	<tr>
		<td align="right">厂商1：</td>
		<td align="left">&nbsp;<select name="factory_id_1" id="factory_id_1">
					<option value=""></option>
					<?php foreach($this->factories as $factory_id => $factory_name):?>
					<option value="<?=$factory_id?>"><?=$factory_name?></option>
					<?php endforeach;?>
				</select>
		</td>
	</tr>
	<tr>
		<td align="right">厂商2：</td>
		<td align="left">&nbsp;<select name="factory_id_2" id="factory_id_2">
					<option value=""></option>
					<?php foreach($this->factories as $factory_id => $factory_name):?>
					<option value="<?=$factory_id?>"><?=$factory_name?></option>
					<?php endforeach;?>
				</select>
		</td>
	</tr>
	<tr>
		<td align="right">厂商3：</td>
		<td align="left">&nbsp;<select name="factory_id_3" id="factory_id_3">
					<option value=""></option>
					<?php foreach($this->factories as $factory_id => $factory_name):?>
					<option value="<?=$factory_id?>"><?=$factory_name?></option>
					<?php endforeach;?>
				</select>
		</td>
	</tr>
	<tr>
		<td colspan="2" align="center"><br><br><input type="button" class="buttonlong" value="提交审核" onclick="submitform();return false;" /></td>
	</tr>
</table>
<br /><br />
</form>
</div>
<br/><br/>
</div>

<script>
<?php if($this->msg):?>
alert("<?=$this->msg?>, 信息提交失败, 请修改后再次提交。");
<?php endif;?>

function submitform() {

    if (document.form1.company_name.value.length == 0) {
        alert("店铺名称不能为空。");
        return false;
    } else if (document.form1.cellphone.value.length == 0) {
        alert("经理手机不能为空。");
        return false;
    } else if (document.form1.pwd.value.length == 0) {
        alert("经理登录密码不能为空。");
        return false;
    } else if (document.form1.dealer_brand.value.length == 0) {
        alert("品牌不能为空。");
        return false;
    }else if( document.form1.dealer_address.value.length == 0 ) {
        alert("经销商地址不能为空。");
        return false;
    }else{
		$.ajax({
			type: "post",
			url : "/ajax/cellphone-available",
			dataType:'json',
            async:false,
			data: {
					'cellphone':document.form1.cellphone.value
				  },
				success: function(json){
					if(json.result == 1) {
                        form1.submit();
                    }else{
						alert("系统中已存在相同手机号，请更换");
						return false;
					}
			}
		});
	}
}

$(function() {
	$( "#expired_date" ).datepicker({ dateFormat: 'yy-mm-dd'});
        $( "#start_date" ).datepicker({ dateFormat: 'yy-mm-dd'});
});
</script>
